<?php


namespace app\api\controller;


use app\common\lib\Show;
use app\common\model\mysql\VideoEpisodes;

class Videos extends ApiBase
{
    /**
     * 热播
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getHot() {
        $w = [
            'status' => 1,
            'is_hot' => 1
        ];
        $model = new \app\common\model\mysql\Videos();
        $res = $model->where($w)->order('id', 'desc')->limit(8)->select();
        return Show::success($res);
    }

    /**
     * 电视剧列表
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getJuji() {
        $w = [
            'status' => 1,
            'type_id' => 1
        ];
        $model = new \app\common\model\mysql\Videos();
        $res = $model->where($w)->order('id', 'desc')->limit(13)->select();
        return Show::success($res);
    }

    /**
     * 综艺
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getZongyi() {
        $w = [
            'status' => 1,
            'type_id' => 2
        ];
        $model = new \app\common\model\mysql\Videos();
        $res = $model->where($w)->order('id', 'desc')->limit(13)->select();
        return Show::success($res);
    }

    public function getPlayList($id) {
        $w = [
            'status' => 1,
            'video_id' => $id
        ];
        $model = new VideoEpisodes();
        $res = $model->where($w)->order('num', 'asc')->select();
        return Show::success($res);
    }

    public function getInfo($id) {
        $w = [
            'status' => 1,
            'id' => $id
        ];
        $model = new \app\common\model\mysql\Videos();
        $res = $model->where($w)->find();
        return Show::success($res);
    }
}